﻿using System;
//
using PerceptiveMCAPI;
//

namespace PerceptiveMCAPI_Test
{
   public partial class get_campaignStats : System.Web.UI.UserControl
   {
      public ApiMethod method { get; set; }

      public string campaignId
      {
         get { return tbCampaignId.Text.Trim(); }
         set { tbCampaignId.Text = value; }
      }
      public int start
      {
         get { return Convert.ToInt32( tbStart.Text.Trim() ); }
         set { tbStart.Text = value.ToString(); }
      }
      public int limit
      {
         get { return Convert.ToInt32( tbLimit.Text.Trim() ); }
         set { tbLimit.Text = value.ToString(); }
      }

      public string email_address
      {
         get { return tbEmail.Text.Trim(); }
         set { tbEmail.Text = value; }
      }
      public string url
      {
         get { return tbUrl.Text.Trim(); }
         set { tbUrl.Text = value; }
      }
      public DateTime since
      {
         get
         {
            DateTime dt; DateTime.TryParse( tbSince.Text, out dt );
            return dt;
         }
         set { tbSince.Text = value.ToString(); }
      }
      public string country_code
      {
         get { return tbCountryCode.Text.Trim(); }
         set { tbCountryCode.Text = value; }
      }

      public void Setup()
      {
         this.Visible = true;
         lblSection.Text = method.section;
         lblMethod.Text = method.name;
         //
         tbCampaignId.Focus();
         spanLimits.Visible = true;
         spanSince.Visible = false;
         spanEmail.Visible = false;
         spanURL.Visible = false;
         spanCountry.Visible = false;
         //
         start = MCAPISettings.default_start;
         limit = 0;
         //
         switch ( method.name )
         {
            case "campaignHardBounces":
               limit = MCAPISettings.default_limit_campaignHardBounces;
               break;
            case "campaignSoftBounces":
               limit = MCAPISettings.default_limit_campaignSoftBounces;
               break;
            case "campaignUnsubscribes":
               limit = MCAPISettings.default_limit_campaignUnsubscribes;
               break;
            case "campaignEmailStatsAIMAll":
               limit = MCAPISettings.default_limit_campaignEmailStatsAIMAll;
               break;
            case "campaignNotOpenedAIM":
               limit = MCAPISettings.default_limit_campaignNotOpenedAIM;
               break;
            case "campaignOpenedAIM":
               limit = MCAPISettings.default_limit_campaignOpenedAIM;
               break;
            case "campaignAbuseReports":
               limit = MCAPISettings.default_limit_campaignAbuseReports;
               spanSince.Visible = true;
               break;
            case "campaignBounceMessages":
               limit = MCAPISettings.default_limit_campaignBounceMessages;
               spanSince.Visible = true;
               break;
            case "campaignEcommOrders":
               limit = MCAPISettings.default_limit_campaignEcommOrders;
               spanSince.Visible = true;
               break;
            case "campaignClickDetailAIM":
               limit = MCAPISettings.default_limit_campaignClickDetailAIM;
               spanURL.Visible = true;
               break;
            case "campaignAdvice":
            case "campaignAnalytics":
            case "campaignEepUrlStats":
            case "campaignEmailDomainPerformance":
            case "campaignStats":
            case "campaignClickStats":
            case "campaignGeoOpens":
               spanLimits.Visible = false;
               break;
            case "campaignGeoOpensForCountry":
               spanLimits.Visible = false;
               spanCountry.Visible = true;
               break;
            case "campaignEmailStatsAIM":
               spanLimits.Visible = false;
               spanEmail.Visible = true;
               break;
         }
      }
   }
}